import os
import shutil
from tqdm import tqdm


SrcDir = r"I:\ImgOutput\BackUp\AmericaRect\BigLabel"
DstDir = r"I:\Temp\Rect\Temp"
CopyFilesType = ["jpg", "xml"]
DontNeedStr = ""

Count = 0

for root, dirs, files in os.walk(SrcDir):
    print("Processing %s..." % root)
    if os.path.exists(root.replace(SrcDir, DstDir)) is False:
        os.makedirs(root.replace(SrcDir, DstDir))
    for file in tqdm(files):
        if file.split(".")[-1] in CopyFilesType:
            if len(DontNeedStr) == 0 or DontNeedStr not in file:
                if os.path.exists(root.replace(SrcDir, DstDir) + "\\" + file) is False:
                    shutil.copyfile(root + "\\" + file, root.replace(SrcDir, DstDir) + "\\" + file)
                    Count += 1
print("Copy %d files in total" % Count)
